<template>
  <!-- 添加或修改盘点计划对话框 -->
  <el-dialog :title="title" v-if="open" v-model="open" width="600px" append-to-body>
    <el-form ref="form" :model="form" :rules="rules" label-width="90px" style="padding-left: 10%;">
      <el-form-item label="模板名称:" prop="templateName">
        <el-input v-model="form.templateName"></el-input>
      </el-form-item>
      <el-form-item label="模板类型:" prop="templateType">
        <el-select v-model="form.templateType" placeholder="请选择模板类型">
          <el-option v-for="item in print_template_type" :key="item.value" :label="item.label"
            :value="item.value"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="模板数据:" prop="templateContent">
        <el-input type="textarea" :rows="4" v-model="form.templateContent"></el-input>
      </el-form-item>
      <el-form-item label="备注:" prop="remark">
        <el-input type="textarea" :rows="4" v-model="form.remark"></el-input>
      </el-form-item>
      <el-form-item label="状态:" prop="templateStatus">
        <el-radio-group v-model="form.templateStatus">
          <el-radio label="1">正常</el-radio>
          <el-radio label="0">停用</el-radio>
        </el-radio-group>
      </el-form-item>
    </el-form>
    <template #footer>
      <div class="dialog-footer">
        <el-button @click="cancel">取 消</el-button>
        <el-button type="primary" @click="submitForm(false)">保存并继续</el-button>
        <el-button type="primary" @click="submitForm">确定</el-button>
      </div>
    </template>
  </el-dialog>
</template>

<script>
import modelMixin from '@/mixins/modelMixin'
import express from '@/api/goods/express';
export default {
  name: "addForm",
  mixins: [modelMixin],
  data() {
    return {
      funcObj: express,//方法对象
      open: false,
      title: "添加模板",
      form: {
        templateStatus: '1',
      },
      rules: {
        templateName: [
          { required: true, message: "模板名称不能为空", trigger: "blur" }
        ],
        templateType: [
          { required: true, message: "请选择模板类型", trigger: "blur" }
        ],
        templateContent: [
          { required: true, message: "模板内容不能为空", trigger: "blur" },
        ],
        templateStatus: [
          { required: true, message: "请选择状态", trigger: "blur" }
        ],
      },
      print_template_type: [],
    }
  },
  methods: {
    add(row = {}) {
      this.open = true;
      this.title = "添加模板";
      this.form = {
        ...row,
        templateStatus: '1',
      }
      console.log('this.form :>> ', this.form);
      this.getDicts(['print_template_type']);
    },

    /**
     * @编辑
     * @param {*} id 
     */
    edit(row) {
      this.open = true;
      this.title = "编辑模板";
      this.getDicts(['print_template_type']);
      this.getDetail(row)
    },
    design(row) {
      this.open = true;
      this.title = "编辑模板";
      this.getDicts(['print_template_type']);
      this.form = row
    },
  }
}
</script>

<style lang="scss" scoped></style>